package com.hxzy.module.merchant.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hxzy.module.merchant.api.merchant.resp.MerchantResp;
import com.hxzy.module.merchant.entity.Business;
import com.hxzy.module.merchant.entity.Merchant;
import com.hxzy.module.merchant.mapstruct.BusinessMapStruct;
import com.hxzy.module.merchant.service.BusinessConfigService;
import com.hxzy.module.merchant.service.BusinessService;
import com.hxzy.module.merchant.service.MerchantService;
import com.hxzy.module.merchant.mapper.MerchantMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 11452
* @description 针对表【merchant(商户表)】的数据库操作Service实现
* @createDate 2024-01-24 09:25:20
*/
@Service
public class MerchantServiceImpl extends ServiceImpl<MerchantMapper, Merchant>
    implements MerchantService{


    /**
     * 查询商户附加业务
     **/
    @Autowired
    private BusinessService businessService;

    /**
     * 获取商户详情
     * @param merchantId
     * @return
     */
    @Override
    public MerchantResp getMerchantDetail(long merchantId) {
        MerchantResp resp=this.baseMapper.getMerchandDetail(merchantId);
        //查询其它插件
        List<Business> businessList = this.businessService.list();
        //使用mapstruct来转换对象
        resp.setBusinessList(BusinessMapStruct.INSTANCE.convert(businessList));

        return resp;
    }
}




